package com.launch.carmanager.data;

import com.launch.carmanager.common.base.BaseResponse;
import com.launch.carmanager.common.base.NullResponse;
import com.launch.carmanager.common.rx.ApiTransformer;
import com.launch.carmanager.common.utils.RetrofitWrapper;
import com.launch.carmanager.data.api.AuthApi;
import com.launch.carmanager.data.dto.AuthDto;
import com.launch.carmanager.data.model.UserInfo;

import rx.Observable;

/**
 * Created by ganquan on 2019/3/28 09:50
 */
public final class ApiInvoker {

    private ApiInvoker() {
        throw new UnsupportedOperationException("u can't instantiate me...");
    }

    /**
     * 授权登录
     * @param phone
     * @param isCheckCode
     * @param registerStatus
     * @return
     */
    public static Observable<UserInfo> login(String phone, String isCheckCode, String registerStatus) {
        return RetrofitWrapper.createApi(AuthApi.class)
                .login(new AuthDto.AuthRequest(phone, isCheckCode, registerStatus).getQueryMap())
                .compose(new ApiTransformer<UserInfo>());
    }

    public static Observable<NullResponse>sendCode(String phone ){
        return RetrofitWrapper.createApi(AuthApi.class)
                .sendCode(new AuthDto.AuthSendCodeRequest(phone).getQueryMap())
                .compose(new ApiTransformer<NullResponse>());
    }


}
